//
//  UIBarButtonItem+Extension.m
//  SinaWeibo-OC
//
//  Created by apple on 15/12/5.
//  Copyright © 2015年 apple. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"

@implementation UIBarButtonItem (Extension)

/**
 *  UIBarButtonItem的便利的构造方法
 *
 *  @param normolImage 普通状态的图片
 *  @param highImage   高亮状态的图片
 *  @param target      监听者
 *  @param action      监听方法
 *
 *  @return 自定义的UIBarButtonItem
 */
+ (UIBarButtonItem*)itemWithImage:(NSString*)normolImage high:(NSString*)highImage target:(id)target action:(SEL)action {
    
    UIButton *btn = [[UIButton alloc] init];
    
    [btn setImage:[UIImage imageNamed:normolImage] forState:UIControlStateNormal];
    
    [btn setImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
    
    btn.size = btn.currentImage.size;
    
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[UIBarButtonItem alloc] initWithCustomView:btn];
    

}
@end
